import BaseCtrl from "../core/mvc/BaseCtrl";
import App from "../App";
import { Protocol } from "../../common/protocol/Protocol";
import { V2Util } from "../../common/game/util/V2Util";

const v2 = V2Util

export default class SnakeCtrl extends BaseCtrl {

    private static _ins: SnakeCtrl
    static get ins() { return SnakeCtrl._ins || (SnakeCtrl._ins = new SnakeCtrl()) }

    ctrlTurn(ang: number) {
        if (this.isLocal) {
            App.localPlayer.ctrlTurn(ang)
        } else {
            this.send(Protocol.C2S_CTRL_TURN, { ang: Math.floor(v2.ang360(ang) * 100) })
        }
    }

    ctrlSprint(isSprint: boolean) {
        if (this.isLocal) {
            App.localPlayer.ctrlSprint(isSprint)
        } else {
            this.send(Protocol.C2S_CTRL_SPRINT, { isSprint })
        }
    }

}